{include file='common/head' /}
<body>
<div class="x-nav">
          <span class="layui-breadcrumb">
              <a><cite>订单管理</cite></a>
              <a><cite>售后列表</cite></a>
          </span>
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" onclick="location.reload()" title="刷新">
        <i class="layui-icon layui-icon-refresh" style="line-height:30px"></i></a>
</div>
<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-body ">
                    <form class="layui-form layui-col-space5">
                        <div class="layui-inline layui-show-xs-block">
                            <input type="number" name="id"  placeholder="序号" autocomplete="off" class="layui-input" value="{$get.id|default=''}">
                        </div>
                        <div class="layui-inline layui-show-xs-block">
                            <input type="text" name="uname"  placeholder="用户名" autocomplete="off" class="layui-input" value="{$get.uname|default=''}">
                        </div>
                        <div class="layui-inline layui-show-xs-block">
                            <input type="text" name="uid"  placeholder="用户ID" autocomplete="off" class="layui-input" value="{$get.uid|default=''}">
                        </div>
                        <div class="layui-inline layui-show-xs-block">
                            <input type="number" name="order_id"  placeholder="订单序号" autocomplete="off" class="layui-input" value="{$get.order_id|default=''}">
                        </div>
                        <div class="layui-inline layui-show-xs-block">
                            <input type="number" name="price"  placeholder="申请金额" autocomplete="off" class="layui-input" value="{$get.price|default=''}">
                        </div>
                        <div class="layui-inline layui-show-xs-block">
                            <input type="number" name="apply_num"  placeholder="申请数量" autocomplete="off" class="layui-input" value="{$get.apply_num|default=''}">
                        </div>
                        <div class="layui-inline layui-show-xs-block">
                            <select name="status">
                                <option value="">状态筛选</option>
                                {volist name="status" id="v"}
                                <option value="{$key + 1}" {if condition="strlen($get['status']) > 0 && $get['status'] == $key"}selected{/if}>{$v}</option>
                                {/volist}
                            </select>
                        </div>
                        <div class="layui-inline layui-show-xs-block">
                            <input class="layui-input"  autocomplete="off" placeholder="申请售后时间开始" name="start" id="start" value="{$get.start|default=''}">
                        </div>
                        <div class="layui-inline layui-show-xs-block">
                            <input class="layui-input"  autocomplete="off" placeholder="申请售后时间截止" name="end" id="end" value="{$get.end|default=''}">
                        </div>
                        <div class="layui-inline layui-show-xs-block">
                            <button class="layui-btn"  lay-submit="" lay-filter="sreach"><i class="layui-icon">&#xe615;</i></button>
                        </div>
                    </form>
                </div>
                <div class="layui-card-header">
                    <span style="line-height:40px;float: right;">共有数据：{$count} 条</span>
                </div>
                <div class="layui-card-body layui-table-body layui-table-main">
                    <table class="layui-table layui-form">
                        <thead>
                        <tr>
                            <th style="text-align: center;">商品图片</th>
                            <th style="text-align: center;">商品名称</th>
                            <th style="text-align: center;">商品规格</th>
                            <th style="text-align: center;">商品单价</th>
                            <th style="text-align: center;">退换货数量</th>
                            <th style="text-align: center;">申请退款</th>
                        </tr>
                        </thead>
                        <tbody>
                        {volist name="list" id="v"}
                        {php}$count=count($v['goods']);{/php}
                        <tr>
                            <td colspan="6">
                                <span onclick="copyCode('{$v.id}')">序号：{$v.id}</span>&nbsp;|&nbsp;
                                {:date('Y-m-d H:i',$v['add_time'])}&nbsp;|
                                <span onclick="copyCode('{$v.uid}')" style="color:red">用户序号：{$v.uid}</span>&nbsp;|&nbsp;&nbsp;
                                <span onclick="copyCode('{$v.name}')" style="color:red">用户昵称：{$v.name}</span>&nbsp;|&nbsp;
                                <span onclick="copyCode('{$v.oid}')">订单序号：{$v.oid}</span>&nbsp;|&nbsp;
                                <span onclick="copyCode('{$v.service_sn}')">售后单号：{$v.service_sn}</span>&nbsp;|&nbsp;
                                <span onclick="copyCode('{$v.apply_num}')">申请数量：{$v.apply_num}</span>&nbsp;|&nbsp;
                                <span onclick="copyCode('{$v.price}')" style="color: red">申请退款金额：{$v.price}</span>&nbsp;|&nbsp;
                                <span onclick="copyCode('{$v.volume}')">购物券退还金额：{$v.volume}</span>&nbsp;|&nbsp;
                                {if $v.status == 5}
                                最终退款：<span style="color:#0193ff;font-weight: bold;">{$v.refund}元</span>&nbsp;|&nbsp;
                                购物券退款：{$v.volume}元&nbsp;|&nbsp;
                                {/if}
                                {if condition="$v['type'] eq 1"}
                                换货
                                {else /}
                                退货退款
                                {/if}&nbsp;&nbsp;
                                <span style="color:{$color[$v['status']]}">{$status[$v['status']]}</span>&nbsp;&nbsp;
                                {if condition="$v['status'] eq 0"}
                                <button class="layui-btn layui-btn layui-btn-xs" title="售后审核"  onclick="xadmin.open('售后审核','/admin/services/examine?id={$v.id}',600,400)" href="javascript:;">
                                    售后审核
                                </button>&nbsp;&nbsp;
                                {/if}
                                {if condition="$v['status'] eq 4 and $v['type'] eq 2"}
                                <button class="layui-btn layui-btn layui-btn-xs" title="确认收货"  onclick="xadmin.open('退款操作','/admin/services/refund?id={$v.id}',600,400)" href="javascript:;">
                                    退款操作
                                </button>&nbsp;&nbsp;
                                {/if}
                                {if condition="$v['status'] eq 3 and $v['type'] eq 1"}
                                <button class="layui-btn layui-btn layui-btn-xs" title="确认收货"  onclick="xadmin.open('确认收货','/admin/services/express?id={$v.id}',600,400)" href="javascript:;">
                                    确认收货
                                </button>&nbsp;&nbsp;
                                {/if}
                                {if condition="$v['status'] eq 4 and $v['type'] eq 1"}
                                <button class="layui-btn layui-btn layui-btn-xs" title="发货编辑"  onclick="xadmin.open('发货编辑','/admin/services/merchantShipment?id={$v.id}',600,400)" href="javascript:;">
                                    发货编辑
                                </button>&nbsp;&nbsp;
                                {/if}
                                {if condition="$v['status'] eq 4 and $v['type'] eq 1"}
                                <button class="layui-btn layui-btn layui-btn-xs" title="发货编辑"  onclick="xadmin.open('发货编辑','/admin/services/merchantShipment?id={$v.id}',600,400)" href="javascript:;">
                                    发货编辑
                                </button>&nbsp;&nbsp;
                                {/if}
                                <button class="layui-btn layui-btn layui-btn-xs" title="售后详情"  onclick="xadmin.open('售后详情','/admin/services/info?id={$v.id}','','',true)" href="javascript:;">
                                    售后详情
                                </button>&nbsp;&nbsp;
                            </td>
                        </tr>
                        {volist name="v['goods']" id="vo"}
                        <tr>
                            <td style="text-align: center;"><a href="{$vo.img}" target="_blank"><img src="{$vo.img}" height="50"></a></td>
                            <td style="text-align: center;">{$vo.title}</td>
                            <td style="text-align: center;">{$vo.attr_str}</td>
                            <td style="text-align: center;">{$vo.price}元</td>
                            <td style="text-align: center;">{$vo.num}</td>
                            <td style="text-align: center;">
                                <span style="color:red;">{$vo.return_price / 100}元</span>
                            </td>
                        </tr>
                        {/volist}
                        <tr>
                            <td colspan="6">
                                {if $v.shop_id && $v.shop_id > 0}
                                    <span onclick="copyCode('{$v.shop_id}')">店铺序号：{$v.shop_id}</span>&nbsp;|&nbsp;
                                {/if}
                                申请售后理由：{$v.apply_reason}
<!--                                买家寄货物流信息-->
                                {if $v.change_express_id > 0 && $v.getOneChangeExpress}
                                <hr>
                                <span style="color: #00A2D4;">买家寄货物流-信息-</span>&nbsp;&nbsp;
                                <span onclick="copyCode('{$express[$v.getOneChangeExpress->company]|default=\'无此物流\'}')">物流公司：{$express[$v.getOneChangeExpress->company]|default='无此物流'}&nbsp;|&nbsp;</span>
                                <span onclick="copyCode('{$v.getOneChangeExpress->express_sn}')">运单号：{$v.getOneChangeExpress->express_sn}&nbsp;|&nbsp;</span>
                                <span onclick="copyCode('{$v.getOneChangeExpress->desc}')">描述：{$v.getOneChangeExpress->desc}</span>
                                {if condition="$v['status'] eq 3 and $v['type'] eq 2"}
                                <button class="layui-btn layui-btn layui-btn-normal layui-btn-xs" title="确认收货"  onclick="receiptFun({$v.id})" href="javascript:;">
                                    确认收货
                                </button>&nbsp;&nbsp;
                                {/if}
                                {/if}
<!--                                卖家发货物流-->
                                {if $v.merchant_express_id > 0 && $v.getOneMerchantExpress}
                                <hr>
                                <span style="color: #00A2D4;">卖家发货物流-信息-</span>&nbsp;&nbsp;
                                <span onclick="copyCode('{$express[$v.getOneMerchantExpress->company]|default=\'无此物流\'}')">物流公司：{$express[$v.getOneMerchantExpress->company]|default='无此物流'}&nbsp;|&nbsp;</span>
                                <span onclick="copyCode('{$v.getOneMerchantExpress->express_sn}')">运单号：{$v.getOneMerchantExpress->express_sn}&nbsp;|&nbsp;</span>
                                <span onclick="copyCode('{$v.getOneMerchantExpress->desc}')">描述：{$v.getOneMerchantExpress->desc}</span>
                                {/if}
                            </td>
                        </tr>
                        {/volist}
                        </tbody>
                    </table>
                </div>
                <div class="layui-card-body ">
                    <div class="page">
                        {$page}
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
<script>
    layui.use(['form','laydate'], function(){
        var laydate = layui.laydate;
        var  form = layui.form;

        //执行一个laydate实例
        laydate.render({
            elem: '#start' //指定元素
        });

        //执行一个laydate实例
        laydate.render({
            elem: '#end' //指定元素
        });

        // 监听全选
        form.on('checkbox(checkall)', function(data){
            if(data.elem.checked){
                $('tbody input').prop('checked',true);
            }else{
                $('tbody input').prop('checked',false);
            }
            form.render('checkbox');
        });
    });

    // 当状态为退款时  且 点击的是 确认收货
    function receiptFun(id){
        layer.confirm('确认收货？',{title:'收货',icon:3},function(index){
            $.ajax({
                url:"/admin/services/receipt",
                type: "post",
                data:{id},
                dataType:"json",
                success:function (res) {
                    if(res.code == 200){
                        layer.alert(res.msg, {icon: 1},function () {
                            window.location = window.location
                        });
                    }else{
                        layer.alert(res.msg, {icon:2,time:1000});
                    }
                },
                error:function(e){
                    layer.alert("网络错误", {icon:5,time:1000});
                },
            });
        });
    }

</script>
{include file='common/copyCode' /}
{include file='common/footer' /}